package com.steven.unittest;

import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Assert;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

/**
 * Created by sulei on 2019/9/8.
 *
 * @author sulei
 */
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class SharedPreferenceDaoTest {
    private static final String TEST_KEY    = "testKey";
    private static final String TEST_STRING = "testValue";

    SharedPreferenceDao spDao;

    @Before
    public void setUp() {
        spDao = new SharedPreferenceDao(InstrumentationRegistry.getContext());
    }

    @Test
    public void test1Read() {
        Assert.assertEquals(null, spDao.get(TEST_KEY));
    }

    @Test
    public void test2ReadWrite() {
        spDao.put(TEST_KEY, TEST_STRING);
        Assert.assertEquals(TEST_STRING, spDao.get(TEST_KEY));
    }
}